﻿#ifndef CDevDataBeltRealign_H
#define CDevDataBeltRealign_H
/********************************************************************************
** @ Date:2025/04/17
** @ Author: HanJiaXin
** @ Description:皮带跑偏设备数据类
** @ Version:1.0.0
** @ ClassName:
** @ Fun:
********************************************************************************/
#include "CDevDataCam.h"
#include "CMeasurePoint.h"

//纠偏读写地址
enum ERWRectifyAddress
{
	//========纠偏状态数据                   
	enCamerBackVal = 1, //摄像机反馈绝对值 400518    发耳:40003
	enCamerLeft,        //摄像机左偏 400519             发耳:40004
	enCamerRight,       //摄像机右偏 400520			   发耳:40005
	enCamerDirBack,     //机摄像机直接反馈 400521    发耳:40001 32位
	enPlcHeartTrig,     //PLC心跳触发 400523         发耳:40026

	enRemoteAuto,       //远程状态下/自动 40527        发耳:40009
	enRemoteMalForeward,//远程手动正转 40528    发耳:40021
	enRemoteMal,        //远程下手动 40529              发耳:40007
	enRemoteMalRevesal, //远程手动反转 40530     发耳:40024
	enComuState,        //通信状态 40531				   发耳:40023
	enErrorAlarm,       //纠偏异常报警 40532           发耳:40008

	//======纠偏反馈数据
	enRemoteCtlFeedback,//远程控制反馈 40544    发耳:40011
	enLocalCtlFeedback, //本地控制反馈 40545     发耳:40012
	enLocalLeftRun,     //本地左偏运行 40546         发耳:40020
	enLocalRightRun,    //本地右偏运行 40547        发耳:40019
	enMotorRunFeedback, //电机运行反馈 40548     发耳:40018
	enLeftYVRunFeedback,//左偏YV运行反馈 40549  发耳:40017
	enRightYVRunFeedback//右偏YV运行反馈 40550  发耳:40016
};

/**
* @ Author: HanJiaXing
* @ Description: 设备控制信息枚举
*/
enum ECCorrectCmdType
{
	enCSetAuto,            //远程自动
	enCSetMananl,		   //远程手动
	enCMalForeward,		   //手动正传
	enCMalForewardStop,	   //停止手动正转
	enCMalRevesal,		   //手动反传
	enCMalRevesalStop,	   //停止手动反转
};

/**
* @ Author: Gaojia
* @ Description: 控制命令执行返回信息枚举
*/

enum ECtrCmdExecReInfo
{
	enSuccess,           //执行成功
	enSetCmdFail,        //设置命令失败
	enResetCtrCmdFail,   //复位执行命令失败
	enResetCtrCmdReFail, //复位执行命令反馈失败
	enResetResultFail,   //复位执行结果失败
	enWriteParamFail,    //写参数失败
	enReadFail,          //读取数据失败
	enPlcNoFeedBack,     //PLC无反馈
	enInterruptCmd,      //控制命令被打断
	enCtrCmeExecOn,      //控制命令执行未完成
	enCtrCmeExecFail,    //控制命令执行失败
	enExecTimeout,       //执行超时 
	enOther,             //其他
};

class CDevDataBeltRealign
{
public:
	CDevDataBeltRealign();
	~CDevDataBeltRealign();
	void resetData();

public:
	QMutex* m_pMutex;					        //数据访问锁
	QString m_sPointGuid;                       //纠偏点GUID
	QString m_sPointName;                       //纠偏点名称
	QString m_sBeltName;				        //归属皮带
	QString m_sPlcIpAddress;                    //纠偏点PLC地址
	int m_nPlcPort;                             //纠偏点PLC端口号
	double m_dLeftRaito;				        //左偏值比率
	double m_dRightRaito;				        //右偏值比率
	double m_dLeftCurrVal;                      //左侧实时偏离值（cm）
	double m_dRightCurrVal;                     //右侧实时偏离值（cm）
	QMap<int, SAddrData> m_mapAddrDataR;        //读 测点序号 测点地址结构体
	QMap<int, SAddrData> m_mapAddrDataW;        //写 测点序号 测点地址结构体
	QDateTime m_qModifyTime;                    //最后修改时间
	QString m_sModifyPerson;                    //修改人
	int m_nIsHaveDev;					        //是否有纠偏设备

	int m_nCamerState;					        //摄像头在线状态 0离线 1在线
	int m_nAlgState;					        //算法在线状态   0离线 1在线
	int m_nAlgNum;						        //算法心跳计数
	int m_nAlgTime;						        //检测算法心跳时间
	int m_nRealignSetValue;				        //判定跑偏设定值一级
	int m_nRealignSetValueTwo;			        //判定跑偏设定值二级
	int m_nAlarmTime;					        //判定生成跑偏报警记录的持续跑偏时间s
	bool m_bIsCorrect;					        //是否一级跑偏
	bool m_bIsCorrectTwo;			            //是否二级跑偏

	int m_nIsHaveBeltRunState;			        //是否有皮带启停信号
	QString m_sBeltStateGuid;			        //皮带启停状态表Guid
	bool m_bBeltWork;					        //皮带启停信号
	int m_nBeltStateType;				        //皮带启停信号获取的方式

	                                            //跑偏结果相关
	int m_nLogNum;						        //判断是否生成报警记录计数
	int m_nDisAlarmNum;					        //判断是否取消报警计数
	QString m_sRecordPath;				        //跑偏结果抓拍保存路径
	bool m_bIsRecord;					        //跑偏结果是否记录
	QString m_sResultGuid;				        //跑偏结果记录Guid
	QString m_sLastAlarmTime;			        //上一次发生报警的时间
	int m_nResultNum;					        //判断是否生成一条新的跑偏结果记录计数
	QVector<double> m_vecLeftValue;				//左侧实时偏移值
	QVector<double> m_vecRightValue;			//右侧实时偏移值

	//PLC相关数据
	bool m_bPlcConnectState;                    //PLC连接状态
	bool m_bPlcConnectStateValue;                    //PLC连接状态
	int m_nRecRemoteAuto;                       //远程状态下自动(0:关闭 1:开启)
	int m_nRecRemoteHand;                       //远程状态下手动(0:关闭 1:开启)
	int m_nRecOffsetValue;                      //偏移量
	int m_nRecCamerLeft;                        //相机左反馈
	int m_nRecCamerRight;                       //相机右反馈
	int m_nRecErrorAlarm;                       //纠偏异常报警

	int m_nRecRemoteCtlFeedback;                //远程控制反馈 
	int m_nRecLocalCtlFeedback;                 //本地控制反馈 
	int m_nRecLocalLeftRun;                     //本地左偏运行 
	int m_nRecLocalRightRun;                    //本地右偏运行 
	int m_nRecMotorRunFeedback;                 //电机运行反馈 
	int m_nRecLeftYVRunFeedback;                //左偏YV运行反馈 
	int m_nRecRightYVRunFeedback;               //右偏YV运行反馈 

	CDevDataCam* m_pDevDataCam;
	QMap<EDevPointType, CMeasurePoint*> m_mapDevPoint;//测点集合
	QMap<QString, QString> m_mapInputPointAddr;//key:输入测点唯一标识，value输入测点地址
	QMap<QString, CMeasurePoint*> m_mapInputPoint;
};

#endif

